<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<table id="mytable" border="1"></table>
		<script>
			let table=document.getElementById("mytable");
			let thead=document.createElement("thead");
			table.appendChild(thead);
			let tr=document.createElement("tr");
			thead.appendChild(tr);
			let th=document.createElement("th");
			tr.appendChild(th);
			th.innerText="姓名";
			th=document.createElement("th");
			tr.appendChild(th);
			th.innerText="语文";
			th=document.createElement("th");
			tr.appendChild(th);
			th.innerText="数学";
			th=document.createElement("th");
			tr.appendChild(th);
			th.innerText="英语";
			
			let arrNames=["小米","小白","小红"];
			let arrYuWens=[80,90,100];
			let arrShuXues=[80,90,100];
			let arrYinYus=[80,90,100];
			
			let tbody=document.createElement("tbody");
			table.appendChild(tbody);
			
			let len=arrNames.length;
			let totalYuWen = 0;
			let totaShuXue = 0;
			let totalYinYu = 0;
			for (let i=0;i<len;i++) {
				
				 tr=document.createElement("tr");
				tbody.appendChild(tr);
				let td=document.createElement("td");
				td.innerText=arrNames[i];
				tr.appendChild(td);
				
				 td=document.createElement("td");
				tr.appendChild(td);
				td.innerText=arrYuWens[i];
				
				 td=document.createElement("td");
				tr.appendChild(td);
				td.innerText=arrShuXues[i];
				
				td=document.createElement("td");
				tr.appendChild(td);
				td.innerText=arrYinYus[i];
				
				totalYuWen +=arrYuWens[i];
				totaShuXue += arrShuXues[i];
				totalYinYu += arrYinYus[i];
				console.log(totaShuXue);
			}
			
			let avgYuWen=totalYuWen / len;
			let avgYinYu=totalYinYu / len;
			let avgShuXue=totaShuXue / len;
			
			 tr=document.createElement("tr");
			tbody.appendChild(tr);
			 td=document.createElement("td");
			tr.appendChild(td);
			td.innerText="平均数";
			
			 td=document.createElement("td");
			tr.appendChild(td);
			td.innerText=avgYuWen;
			
			 td=document.createElement("td");
			tr.appendChild(td);
			td.innerText=avgYinYu;
			
			td=document.createElement("td");
			tr.appendChild(td);
			td.innerText=avgShuXue;
			
		</script>
	</body>
</html>
